function Deck() {
    this.stack = new Array();
    this.current = 0;
    Log.logWithFacility( "DECK", "Creating new Deck" );
}

Deck.prototype.addCard = function ( card ) {
    if( null != card ) {
	this.stack[ this.stack.length ] = card;
	Log.logWithFacility( "DECK", "Adding Card (" + card.name + ")" );
    } else {
	Log.logWithFacility( "DECK", "Attempted to add card, but card was null." );
    }
};

Deck.prototype.setCurrent = function( current ) {
    if( ( current < 0 ) || ( current >= this.stack.length ) ) {
	Log.logWithFacility( "DECK", "Attempting to set current card to #" + current + ", but it's out of range." );
    } else {
	this.current = current;
	this.draw();
	Log.logWithFacility( "DECK", "Setting Current Card to card #" + current + " (" + this.stack[current].name + ")" );
    }
};

Deck.prototype.draw = function () {
    Log.logWithFacility( "DECK", "Drawing Deck" );
    document.getElementById("left").innerHTML = this.createMenu();
    this.stack[ this.current ].draw();
};

Deck.prototype.createMenu = function () {
    var menuText = "";
    var itemClass;

    for( var i = 0; i < this.stack.length; i++ ) {
        if( this.current == i ) {
            itemClass = "middleitemselected";
        } else {
            itemClass = "middleitem";
        }
        menuText += "<tr><td class=\"" + itemClass + "\" onclick=\"deck.setCurrent(" + i + ");\">&nbsp;" + this.stack[i].getName() + "</td></tr>";
    }

    return( menuText );
};